### SUPPLEMENTARY MATERIAL S5: OBSERVATIONALS STUDY: PRESIDENTIAL SEX SCANDALS -- Figure S5

library(ggplot2)
library(ggpubr)
library(cowplot)
library(lubridate)
library(tidyverse)

trump <- read.csv("pres_approve.csv", header=TRUE, sep=",")

trump$date <- mdy(trump$End.Date)
trump$net <- trump$Approving-trump$Disapproving
trump$pres <- "Donald J. Trump"

clinton <- read.csv("pres_approve2.csv", header=TRUE, sep=",")

clinton$date <- mdy(clinton$End.Date)
clinton$net <- clinton$Approving-clinton$Disapproving
clinton$pres <- "Bill Clinton"

trump_plot <- ggplot(trump, aes(x=date, y=net)) +
  geom_line(size=1) + theme_bw() +
  theme(axis.text.x=element_text(angle=0, hjust=1, size=10),
        axis.text.y=element_blank(),
        axis.title.y=element_blank()) + 
  ylab("Net Approval") +
  xlab("") + scale_x_date(date_labels = "%Y %b %d",
                          limit=c(as.Date("2017-12-25"),as.Date("2018-06-01"))) + theme(axis.text.x=element_text(angle=30, hjust=1)) + 
  geom_vline(xintercept= as.numeric(as.Date("2018-01-13")), linetype=3, size=1, color="red") + ## Stormy D. alleg.
  geom_vline(xintercept= as.numeric(as.Date("2018-01-25")), linetype=3, size=1, color="red") + ## Trump denies
  geom_vline(xintercept= as.numeric(as.Date("2018-02-12")), linetype=3, size=1, color="red")  + ## Cohen admits
  geom_vline(xintercept= as.numeric(as.Date("2018-03-06")), linetype=3, size=1, color="red")  +## Stormy lawsuit, Trump denies
  geom_vline(xintercept= as.numeric(as.Date("2018-03-25")), linetype=3, size=1, color="red") + ## 60 mins interview, Trump still denies
  geom_vline(xintercept= as.numeric(as.Date("2018-04-01")), linetype=3, size=1, color="red")  + ## Trump denies
  geom_vline(xintercept= as.numeric(as.Date("2018-04-09")), linetype=3, size=1, color="red")  +## Cohen faces crim. investigation
  geom_vline(xintercept= as.numeric(as.Date("2018-04-20")), linetype=3, size=1, color="red") + ## Trump denies
  geom_vline(xintercept= as.numeric(as.Date("2018-05-05")), linetype=3, size=1, color="red") + ## Trump admits
  geom_text(aes(x = as.Date("2018-01-09"), y = 30, label = "Stormy D. alleg."), angle=90, size=4) + 
  geom_text(aes(x = as.Date("2018-01-21"), y = 30, label = "Trump denies"), angle=90, size=4) +
  geom_text(aes(x = as.Date("2018-02-08"), y = 30, label = "Cohen admits"), angle=90, size=4) +
  geom_text(aes(x = as.Date("2018-02-27"), y = 30, label = "Stormy D. lawsuit, \n Trump denies"), angle=90, size=4) +
  geom_text(aes(x = as.Date("2018-03-18"), y = 30, label = "Interview with Stormy D., \n Trump denies"), angle=90, size=4) +
  geom_text(aes(x = as.Date("2018-03-29"), y = 30, label = "Trump denies"), angle=90, size=4) +
  geom_text(aes(x = as.Date("2018-04-06"), y = 30, label = "Cohen arrested"), angle=90, size=4) +
  geom_text(aes(x = as.Date("2018-04-17"), y = 30, label = "Trump denies"), angle=90, size=4) +
  geom_text(aes(x = as.Date("2018-05-02"), y = 30, label = "Trump admits"), angle=90, size=4) +
  ggtitle("Trump: Stormy Daniels Scandal Timeline") + ylim(-30,50)
  
trump_plot

Sys.setlocale("LC_TIME", "English")

clinton_plot <- ggplot(clinton, aes(x=date, y=net)) +
  geom_line(size=1) + theme_bw() +
  xlab("") + scale_x_date(date_labels = "%Y %b %d",
                          limit=c(as.Date("1998-01-01"),as.Date("1999-02-01"))) + 
  theme(axis.text.x=element_text(angle=30, hjust=1, size=10),
                                 axis.text.y=element_text(angle=0, hjust=1, size=12),
                                 axis.title.y=element_text(angle=90, hjust=0.5, size=13)) + 
          ylab("Net Approval") + geom_vline(xintercept = as.numeric(as.Date("1998-01-19")),
                                                                                         linetype=3, size=1, color="red") +
  geom_vline(xintercept = as.numeric(as.Date("1998-02-01")),
             linetype=3, size=1, color="red") +
  geom_vline(xintercept = as.numeric(as.Date("1998-08-14")),
             linetype=3, size=1, color="red") +
  geom_vline(xintercept = as.numeric(as.Date("1998-12-20")),
             linetype=3, size=1, color="red") +
  geom_text(aes(x = as.Date("1998-01-10"), y = -15, label = "Lewinsky Alleg."), angle=90, size=4) + 
  geom_text(aes(x = as.Date("1998-02-08"), y = -15, label = "Clinton Denies"), angle=90, size=4) +
  geom_text(aes(x = as.Date("1998-08-05"), y = -15, label = "Clinton Admits"), angle=90, size=4) +
  geom_text(aes(x = as.Date("1998-05-01"), y = 5, label = "Legal Investigations"), angle=0, size=4) +
  geom_text(aes(x = as.Date("1998-12-11"), y = -10, label = "House Impeachment"), angle=90, size=4) +
  geom_segment(aes(x=as.Date("1998-02-10"), y=0, xend=as.Date("1998-08-10"), yend=0), linetype=3, size=1, color="red") +
  ggtitle("Clinton: Lewinsky Scandal Timeline") + ylim (-30,50)
  
clinton_plot

plot_grid(clinton_plot, trump_plot)

#ggsave("fig_s5.png", width = 14, height = 7, dpi = 600)         
